﻿using Cofe.Core.Security;
using Cofe.Core.Utils;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Cofe.Core.Service;

namespace Cofe.Core.Property
{
    /// <summary>
    /// Base interface for providing COFE Property support.
    /// </summary>
    /// <typeparam name="T">The interface the class implementing
    /// (IFileSystemInfo, IEntryList, IEventLog), 
    /// for obtain secondary property.</typeparam>
    public interface IPropertyHost : IProtectedData<IPropertyHost>
    {
        PropertyHostState State { get; set; }

        /// <summary>
        /// Cache for properties, the setter is available for ORM only.
        /// </summary>
        IPropertyCache PropertyCache { get; set; }

        IPropertyProvider PrimaryPropertyProvider { get; }
        /// <summary>
        /// Call ConnectAsync if not connected.
        /// </summary>
        IPropertyProvider PrimaryPropertyProviderChecked { get; }
        IPropertyProvider[] SecondaryPropertyProviders { get; }

        IPropertyProvider[] AllPropertyProviders { get; }

        /// <summary>
        /// Return a list of supported property definitions, not all property in the definitions is necessary supported.
        /// Use IsPropertySupported to make sure the property is supported.
        /// </summary>
        IPropertyDefinitions[] SupportedDefinitions { get; }

        /// <summary>
        /// Get/Set/List/Invoke property in PropertyProviders
        /// </summary>
        IPropertyBehaviorManager Behaviors { get; }

        IServiceLocater ServiceLocater { get; set; }                  

        /// <summary>
        /// Call IPropertyCacheUpdater to update Primary/SecondaryPropertyProviders properties to PropertyCache.
        /// </summary>
        /// <returns></returns>
        Task CachePropertiesAsync();


        /// <summary>
        /// Construct PrimaryPropertyProvider, compare it's LastWriteTime to PropertyCache's, 
        /// and clear PropertyCache if not equal.
        /// </summary>
        /// <returns></returns>
        Task ConnectAsync();

        void Disconnect();
    }

    

}
